<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');

include_once('../arc2-starter-pack/config.php');
$store = ARC2::getStore($arc_config);

$output = array();

$q = "
prefix dct:<http://purl.org/dc/terms/>
prefix xsd:<http://www.w3.org/2001/XMLSchema#>
select distinct ?paper ?title where{
	?paper dct:creator <".$_GET["uri"].">.
	?paper dct:creator <".$_GET["other"].">.
	?paper dct:title ?title.
	?paper dct:date ?date.
	filter regex(?date,'".$_GET["date"]."')
}
order by ?title
";
$rows = $store->query($q, 'rows');

foreach ($rows as $row) {
	$uri = $row["paper"];
	$title = $row["title"];
	$article = array();
	$article["label"] = "".$title;
	$article["uri"] = "".$uri;
	$output[] = $article;
}


# output as json
header('Content-type: text/plain');
echo json_encode($output);

?>
